The Movie Toolbox provides a number of functions that allow applications to determine information about a movie's sample data. This section discusses these functions. Refer to "Adding Samples to Media Structures," for information about functions that allow you to retrieve sample data from a media.
Your application can use the GetMovieDataSize , GetTrackDataSize , and GetMediaDataSize functions to determine the size, in bytes, of the data stored in a media, movie, or track.
You can use the GetMediaSampleDescriptionCount and GetMediaSampleDescription functions to retrieve a media's sample descriptions. The SetMediaSampleDescription function enables you to change the contents of a particular sample description associated with a media. The GetMediaSampleCount function determines the number of samples in a media. The SampleNumToMediaTime and MediaTimeToSampleNum functions allow you to convert from a time value to a sample number and vice versa. You can use the functions described in "Finding Interesting Times," to locate specific samples in a media.
The GetMovieDataSize function allows your application to determine the size, in bytes, of the sample data in a segment of a movie.
pascal long GetMovieDataSize (Movie theMovie, TimeValue startTime,
TimeValue duration);
The GetMovieDataSize function returns a long integer that contains the size, in bytes, of the movie's sample data that lies in the specified segment. GetMovieDataSize counts each use of a sample. That is, if a movie uses a given sample more than once, the size of that sample is included in the returned size value one time for each use. Consequently, the returned size is greater than or equal to the actual size of the movie's sample data, and corresponds to the amount of movie data that will be retrieved when you call the FlattenMovie function or FlattenMovieData function (described on FlattenMovie and FlattenMovieData , respectively).
The GetTrackDataSize function allows your application to determine the size, in bytes, of the sample data in a segment of a track.
pascal long GetTrackDataSize (Track theTrack, TimeValue startTime,
TimeValue duration);
The GetTrackDataSize function returns a long integer that contains the size, in bytes, of the track's sample data that lies in the specified segment.
This function counts each use of a sample. That is, if a track uses a given sample more than once, the size of that sample is included in the returned size value one time for each use. Consequently, the returned size is greater than or equal to the actual size of the track's sample data.
The GetMediaDataSize function allows your application to determine the size, in bytes, of the sample data in a media segment.
pascal long GetMediaDataSize (Media theMedia, TimeValue startTime,
TimeValue duration);
The GetMediaDataSize function returns a long integer that contains the size, in bytes, of the media's sample data that lies in the specified segment. Note that this number does not necessarily correspond to the amount of sample data used in the track that contains the media. Some samples in the media may not be used in the track, and others may be used more than once.
The GetMediaSampleCount function allows you to determine the number of samples in a media.
pascal long GetMediaSampleCount (Media theMedia);
The GetMediaSampleCount function returns a long integer that contains the number of samples in the specified media. Note that this number does not necessarily correspond to the number of samples used in the track that contains the media. Some samples in the media may not be used in the track, and others may be used more than once.
The GetMediaSampleDescriptionCount function returns the number of sample descriptions in a media.
pascal long GetMediaSampleDescriptionCount (Media theMedia);
The Movie Toolbox identifies a media's sample descriptions with an index value. Index values always range from 1 to the number of sample descriptions in the media. Sample description indexes provide a convenient way to access each sample description in a media.
The format of sample descriptions differs by media type. Sample descriptions for image data are defined by image description structures, which are discussed in the chapter "Image Compression Manager" in this book. Sample descriptions for sound are defined by sound description structures, which are discussed in "The Sound Description Structure," . Sample descriptions for text are defined by text description structures, which are described in "Text Media Handler Functions" beginning on Text Media Handler Functions .
The GetMediaSampleDescription function allows you to retrieve a sample description from a media.
pascal void GetMediaSampleDescription (Media theMedia, long index,
SampleDescriptionHandle descH);
This function provides a convenient way to retrieve information that describes a sample. For example, you can use this function to retrieve an image media's color lookup table.
The format of sample descriptions differs by media type. Sample descriptions for image data are defined by image description structures, which are discussed in the chapter "Image Compression Manager" in this book. Sample descriptions for sound are defined by sound description structures, which are discussed earlier in this chapter. Sample descriptions for text are defined by text description data structures, which are described in "Text Media Handler Functions," .
The Movie Toolbox identifies a media's sample descriptions with an index value. Index values always range from 1 to the number of sample descriptions in the media. Sample description indexes provide a convenient way to access each sample description in a media.
The SetMediaSampleDescription function lets you change the contents of a particular sample description of a specified media.
pascal OSErr SetMediaSampleDescription (Media theMedia,
long index,
SampleDescriptionHandle descH);
The SetMediaSampleDescription function can be useful in the case of a media handler, such as a text media handler, that stores playback information in its sample description, as opposed to just data format information (as in the case of the video media handler). For more on media handlers, see Inside Macintosh: QuickTime Components .
The MediaTimeToSampleNum function allows you to find the sample that contains the data for a specified time. You indicate the time in the media's time scale.
pascal void MediaTimeToSampleNum (Media theMedia, TimeValue time,
long *sampleNum,
TimeValue *sampleTime,
TimeValue *sampleDuration);
The Movie Toolbox returns information about the sample that contains data for that time, including its starting time, duration, and sample number.
The MediaTimeToSampleNum function does not account for edits applied to the media by a movie's tracks. If you want to work with edits, use the functions that allow you to look for interesting times. These functions are described in "Finding Interesting Times," beginning on Finding Interesting Times .
The SampleNumToMediaTime function allows you to find the time at which a specified sample plays. This time is expressed in the media's time scale.
pascal void SampleNumToMediaTime (Media theMedia,
long logicalSampleNum,
TimeValue *sampleTime,
TimeValue *sampleDuration);